Advanced Linux Commands

By Prabhav Adhikari

alias

  • Launch any command or group of commands by entering a pre-set string
  • Allows a user to create simple names or abbreviations for commands

Basic Syntax


alias <String> = <Command>


Examples

alias p = "pwd"

Alias


An alias can be created with the same name as the core name of a command


An alias named ls could be created for the command ls -al


alias ls= "ls -al"

Alias


Multiple commands can be included in the same alias


Insert them within the same pair of quotation marks and Separate them with semicolons


alias pl = 'pwd; ls'

Alias


Aliases can even be created to call other aliases

alias l='ls -a'

alias pl='p; l'


Aliases can be used with any argument that the command can be used with

l /home/Documents

Alias

Any alias set up with it remains in effect only during the current login session

Type alias only to see a list of aliases.

Use unalias alias-name to remove an alias

bc

A basic Calculator


In the bc environment type expressions and get their results

5*5+3*23

Use last to use last answer in your expression.

last * 2 - 1

I/O Redirection

Pipe

Symbol used to provide output of one command as input to another command

>

Used to direct the output to a file.

>>

Used to append the output to a file

grep

Used to search text for patterns specified by the user

Basic Syntax:

grep <pattern> <file>

To see the occurances of 'is' in a file 'Intro.txt':
grep 'is' Intro.txt

ping

Used to check if an address is accessible

Syntax: ping <destination>

ping transmits packets to the address and checks if it is received

To restrict number of packets use ping -c <no>

Example ping -c 5 google.com

ps

Used to provide information about the currently running processes including their process identification numbers (PIDs)

Syntax: ps

kill

Used to kill a process.

Syntax: kill <pid>

tty

TeleTYpewriter

There are 6 virtual consoles in Ubuntu

They can be accessed by the keyboard shortcuts

Ctrl + Alt + F1 - F7

tty 1 to 6 have text UI while 7th has Graphics UI.

let's go on